package leetcode.templates.presum;

public class PreSum {

	public long[] presum(int[] nums) {
		int len = nums.length;
		long[] sums = new long[len + 1];
		for (int i = 1; i < sums.length; i++) {
			sums[i] = sums[i - 1] + nums[i - 1];
		}
		return sums;
	}
	
	public long sumIndex(long[] sums, int indexL, int indexR) {
		return sums[indexR + 1] - sums[indexL];
	}
	
}
